package com.example.helloworld;

/**
 * ClassName: YangHuiTest
 * Package: com.example.helloworld
 * Description:
 *
 * @Author guotingting
 * @Create 2025/4/21 10:11 AM
 * @Version 1.0
 */
public class YangHuiTest {
    public static void main(String[] args) {
        int[][] yangHui = new int[10][];
        for (int i = 0; i < yangHui.length; i++) {
            yangHui[i] = new int[i + 1];
            yangHui[i][0] = 1;
            yangHui[i][i] = 1;
            for (int j = 1; j < yangHui[i].length - 1; j++) {
                yangHui[i][j] = yangHui[i - 1][j - 1] + yangHui[i - 1][j];
            }
        }

        // 打印杨辉三角
        for (int i = 0; i < yangHui.length; i++) {
            for (int j = 0; j < yangHui[i].length; j++) {
                System.out.print(yangHui[i][j] + " ");
            }
            System.out.println();
        }
    }
}
